<?php
$CryptPID = array();
if( isset($_POST["encrypt"]) && isset($_POST["mid"]) ){
$target = preg_split("/(\r\n|\n|\r)/",$_POST["mid"]);
foreach($target as &$val){
if (!(empty($val))){
array_push($CryptPID,$val);
}
}
unset($val);
//Get 暗号化済会員ID
$sql = "Select mid,id from tempURLs where rid in (";
for($i=0;$i<count($CryptPID);$i++)
{
if ($i == (count($CryptPID)-1))
$sql= $sql . "\"" . $CryptPID[$i] . "\")";
else
$sql= $sql . "\"" . $CryptPID[$i] . "\",";
}
$db = mysql_connect("mysql513.in.shared-server.net:16033", "JRtu434", "qvoiceDB1");
mysql_select_db("JRtu434", $db);
$res = mysql_query($sql);
$ID = array();
$DecryptMID = array();
//Decrypt 暗号化済会員ID
while ($row = mysql_fetch_array($res))
{
array_push($ID,$row[1]);
array_push($DecryptMID,$row[0]);
}
unset($val);
mysql_close();
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>会員IDの暗号化・復号化</title>
<style type="text/css">
* {
margin: 0px;
padding: 0px;
}

div.main {
text-align: center;
margin: 0px auto;
padding: 0px auto;
}

div.head {
margin: 20px;
}

div.button {
margin: 10px;
width: 150px;
}

div.button input {
margin: 20px;
padding: 10px;
}

form,table {
text-align: center;
margin: 0px auto;
padding: 0px auto;
}
</style>
<?php include 'layout.php'; ?> 
</head>
<body>
<div id="content">
<div class="main">
<div class="head">会員IDをダウンロード。</div>
<form action="kaiinid.php" method="post">
<table>
<tr>
<th>ふつうのリサーチ暗号</th>
<th></th>
<th>PHPの会員ID</th>
<th>ふつうの会員暗号</th>
</tr>
<tr>
<td><textarea name="mid" rows="20" cols="20"><?php
if( isset($_POST["encrypt"]) && isset($_POST["mid"])){
echo $_POST["mid"];
}
?></textarea></td>
<td>
<div class="button"><input type="submit" value="ダウンロード　会員ID"
name="encrypt"></input>
</td>
<td><textarea name="id" rows="20" cols="20"><?php
if( isset($_POST["encrypt"]) && isset($_POST["id"])){
foreach($ID as &$r){
echo $r . "\r\n";
}
}
?></textarea></td>
<td><textarea name="uid" rows="20" cols="20"><?php
if( isset($_POST["encrypt"]) && isset($_POST["uid"])){
foreach($DecryptMID as &$r){
echo $r . "\r\n";
}
}
?></textarea></td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>
